import dayjs from 'dayjs';
import "dayjs/locale/zh-cn.js";
import relativeTime from 'dayjs/plugin/relativeTime';

dayjs.extend(relativeTime)


export function fromNow(t) {
  // t: "2025-04-07T22:39:40.000" 或 "2025-04-07T22:39:40.000+08:00"
  if (!t) return "";
  let r =  dayjs(t).locale("zh-cn").fromNow()
  if (r === '几秒后' || r === '几秒前') {
    r = '刚刚'
  }
  return r
}